import {
  Select,
  Input
} from '@/components/CustomPage/fields/widget'

export function sourceOption() {
  return [
    {
      type: Select,
      option: {
        label: '资源来源',
        name: 'dataSource',
        list: [{ name: '专区', value: 'zq' }, { name: '系统', value: 'xt' }],
        value: 'zq',
        override: function(ths, e) {
          ths.$nextTick(() => {
            for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
              if (ths.$parent.$parent.$children[i].option.fType === 1) {
                ths.$parent.$parent.$children[i].visible = e === 'zq'
              }
            }
          })
        }
      }
    },
    { type: Select, option: { label: '资源类型', name: 'souMold', fType: 1, required: false, visible: true,
      async: '/backend/sysDictionary/getDictByCode',
      asyncParams: {
        dictCode: 'ZYLX'
      },
      value: ''
    }
    },
    { type: Input, option: { label: '展示数量', name: 'pageSize', required: false }},
    { type: Input, option: { label: '分类标签', name: 'classLabel', fType: 1, required: false }}
  ]
}

/**
 * 没有展示数量的
 */
export function sourceNoNumOption() {
  return [
    {
      type: Select,
      option: {
        label: '资源来源',
        name: 'dataSource',
        list: [{ name: '专区', value: 'zq' }, { name: '系统', value: 'xt' }],
        value: 'zq',
        override: function(ths, e) {
          ths.$nextTick(() => {
            for (let i = 0; i < ths.$parent.$parent.$children.length; i++) {
              if (ths.$parent.$parent.$children[i].option.fType === 1) {
                ths.$parent.$parent.$children[i].visible = e === 'zq'
              }
            }
          })
        }
      }
    },
    { type: Select, option: { label: '资源类型', name: 'souMold', fType: 1, required: false, visible: true,
      async: '/backend/sysDictionary/getDictByCode',
      asyncParams: {
        dictCode: 'ZYLX'
      },
      value: ''
    }
    },
    { type: Input, option: { label: '分类标签', name: 'classLabel', fType: 1, required: false }}
  ]
}
